#ifndef PROTOCOLDIALOG_H
#define PROTOCOLDIALOG_H

#include <QDialog>
#include <QMap>
#include <QVector>
#include <QTreeWidgetItem>
#include "pugixml/pugixml.hpp"
using namespace pugi;
namespace Ui {
class ProtocolDialog;
}

class ProtocolDialog : public QDialog
{
    Q_OBJECT


public:
    enum Protocal_Type
    {
        Collect_Type,
        Update_Type
    };

    struct ProtocalInfo
    {
        QString categoryName;
        QString protoName;
        QString factoryName;
        QString desc;
    };

public:
    explicit ProtocolDialog(QWidget *parent = nullptr);
    ~ProtocolDialog();
    void SetProtocalType(Protocal_Type type);
    QString GetSelectProtoName();
    QString GetSelectProtoCate();
private slots:
    void on_treeWidget_itemClicked(QTreeWidgetItem *item, int column);

    void on_pushButton_clicked();

    void on_pushButton_2_clicked();

private:
    void getDirectName(QString strDirect);
    void parseXmlFile(QString fileDirect);//解析协议XML文件

private:
    Ui::ProtocolDialog *ui;
    Protocal_Type m_type;
    QMap<QString,QVector<QString>> m_mapCategory;        //类别
    QMap<QString,ProtocalInfo> m_mapProtocal;   //协议
    QString m_protoName;
    QString m_protoCate;
};

#endif // PROTOCOLDIALOG_H
